<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/assets/cashier/css/main.css"/>
    <link rel="stylesheet" href="/assets/cashier/css/iconfont.css">
    <link rel="stylesheet" href="/assets/cashier/css/print.css">
    <script type="text/javascript" src="/assets/cashier/js/jquery-1.11.3.js"></script>
    <script type="text/javascript" src="/assets/cashier/js/main.js"></script>
     <script type="text/javascript" src="/assets/cashier/js/jquery.jqprint-0.3.js"></script>
    <script type="text/javascript" src="/assets/cashier/js/jquery-migrate-1.2.1.min.js"></script>
    <title>挂单</title>
</head>
<body>
    <div class="container">
        <div class="nav">
            <div class="user-head">
                <img src="/assets/logo.png"/>
            </div>
            <div class="nav-con">
                <ul>
                     <li class="nav-list">
                        <a href="/cashier/index/index/index">
                            <span class="iconfont icon-shouyin"></span>
                            <p data-locale="msg_shouyin">收银台</p>
                        </a>
                    </li>
                    <li class="nav-list active">
                        <a href="/cashier/index/index/order">
                            <span class="iconfont icon-guadan"></span>
                            <p data-locale="msg_guadan">挂单</p>
                        </a>
                    </li>
                    <li class="nav-list">
                        <a href="/cashier/index/index/members">
	                        <span class="iconfont icon-huiyuan"></span>
	                        <p data-locale="msg_huiyuan">会员</p>
                        </a>
                    </li>
                    <li class="nav-list">
                        <a href="/cashier/index/index/count">
                            <span class="iconfont icon-tongji"></span>
                            <p data-local="msg_tongji">统计</p>
                        </a>
                    </li>
                    <li class="nav-list">
                        <a href="/cashier/index/index/change">
                            <span class="iconfont icon-tuihuo"></span>
                            <p data-locale="msg_tuihuanhuo">退换货</p>
                        </a>
                    </li>
                </ul>
            </div>
            <div class="nav-foot">
                <div class="nav-foot-list nav-lock">
                    <span class="iconfont icon-suo"></span>
                    <p data-locale="suoding">锁定</p>
                </div>
                <div class="nav-foot-list nav-cancel">
                    <a href="/cashier/index/index/exchange">
                        <span class="iconfont icon-tuichu"></span>
                        <p data-locale="msg_jiaoban">交班</p>
                    </a>
                </div>
            </div>
        </div>
        <div class="content">
            <div class="custom-con">
                <ul>
                    
                </ul>
            </div>
            <div class="shop-pages" style="position: relative; margin-top: 20px;"></div>
        </div>
    </div>
    <div class="popbg">
        <!--锁定-->
         <div class="popbox" id="lock">
            <div class="pop-head" data-locale="msg_qxsd">请填写你的密码取消锁定</div>
            <div class="pop-body">
                <input class="lock-input" name="password">
            </div>
            <div class="pop-foot">
                <div class="centerButton lock-btn" data-locale="msg_queren">确认</div>
            </div>
        </div>
        <div id="online" class="print-online">
        	<div class="code"><img src="../../../assets/logo.png"/></div>
			<div class="title">日出行中国超市</div>
			<div class="en-title">Sunrise Chinese Market Ltd</div>
			<div class="address">
				<p>84 Colman Road, Norwich, NR4 7EH</p>		
				<p>01603 927952	</p>	
			</div>
			
			<div class="line-type"><span class="pull-left">ON-LINE</span><span class="pull-right">顾客线上消费送货小票</span></div>
			<div class="print-list">送货时间：<span class="delivery-time"></span></div>
			<div class="print-list">收银员工：<span class="cashier-name"></span></div>
			<div class="print-list">消费时间：<span class="order-time"></span></div>
			<div class="print-list">线上订单：<span class="order_id"></span></div>
			
			<div class="print-list vip-name-box">会员姓名：<span class="vip-name"></span></div>
			<div class="print-list">微信号码：<span class="vip-weixin"></span></div>
			<div class="print-list">送货地址：<span class="vip-address"></span></div>
			<div class="print-list">送货邮编：<span class="vip-site"></span></div>
			<div class="print-list">联系电话：<span class="vip-phone"></span></div>
			<div class="print-list">备注：<span class="vip-remark"></span></div>
			<div class="print-list">支付方式：<span class="print-order-payMode"></span></div>
			<div class="line"></div>
			<div class="print-table-head">
				<span>单价(￡)</span>
				<span>数量</span>
				<span>金额(￡)</span>
			</div>
			<div class="line"></div>
			<div class="print-table-body"> </div>
			<div class="line"></div>
			<div class="print-table-head">
				<span>共计</span>
				<span class="print-table-total-food"></span>
				<span class="print-table-total-price"></span>
			</div>
			<div class="line"></div>
			<div class="consumption"></div>
			
			<div class="line"></div>
			<div class="print-list text-center">VAT RECEIPT SUMMARY</div>
			<div class="print-list text-center">NET：<span class="vat-net"></span></div>
			<div class="print-list text-center">20%VAT：<span class="vat-20"></span></div>
			<div class="print-list text-center">GROSS：<span class="vat-gross"></span></div>
			<div class="print-list text-center">VAT No. : 157965263</div>
			<div class="line"></div>
			<div class="print-time">打印时间：<span class="print-time-detail"></span></div>
			<div class="print-time">感谢惠顾，期待您的再次光临</div>
			<div class="print-time">加入会员，更多折扣，更多优惠，更多方便</div>
			<div class="print-time">扫我↓</div>
			<div class="code"> <img src="../../../assets/cashier/img/richubao.jpg" /></div>
		</div>
    </div>
    <div class="tip hide"></div>
    <script type="text/javascript">
        $(function () {
           lock();
            //删除挂单
            $('body').on('click','.btn-left',function () {
                var id=$(this).parents('.order-list').attr('data-id');
                var params={id:id};
                var that=this;
                $.ajax({
                	type:"POST",
                	data:params,
                	dataType:'json',
                	url:urlHead+'/order/delete_bill',
                	success:function(json){
                		$(that).parents('.order-list').hide();
                		tip(lang('ORDER_DELETE_SUCCESS'))
                	}
               
                })
            });

            var units=SITE_CONFIG.units;
            var order_page=1,total_page=1,order=[];
            $('body').on('click','.page-next',function(){
                if (parseInt(order_page)+1 <= total_page) {
                   order_page++;
                   getOrder()
                }
            });
            $('body').on('click','.page-prev',function(){
                if (parseInt(order_page)-1 > 0) {
                    order_page -= 1;
                    getOrder()
                }
            });
            $('body').on('click','.page-target',function(){
                order_page = parseInt($(this).html());
                getOrder()
            });
            getOrder()
            function getOrder(){
                var params={page:order_page};
                $.ajax({
                    type:'GET',
                    data:params,
                    url:urlHead+'/order/get_bills',
                    dataType:'json',
                    success:function(json){
                        console.log(json)
                        var page=json.current_page;
                        var total=json.last_page;
                        total_page = json.last_page;
                        var page_size=json.page_size;

                        order=json.data;
                        var li='';
                        if(order.length>0){
							
	                        $.each(order,function(index,item){   
	                        	var user_name = SITE_LANG=='chinese'? '普通用户':'average user'; 
	                            li+='<li class="custom order-list" data-id="'+item.id+'">';   
	                            if(item.user_id == 0){
	                                li+='<div class="custom-head" >'
	                                    + '<div class="ordinary">'
	                                    +    '<div class="custom-head-img">'
	                                    +       '<img src="/assets/avatar.png"/>'
	                                    +   '</div>'
	                                    +    '<div class="custom-head-con">'
	                                    +        '<div class="customer">'+user_name+'</div>'
	                                    +    '</div>'
	                                    + '</div>'
	                                    +'</div>';
	
	                            }else{
	                            	if(item.user.nickname) user_name = item.user.nickname;
		                        	if(item.user.first_name && item.user.last_name) user_name = item.user.first_name+' '+item.user.last_name;
		                        	user_name+='('+item.user.phone+')';
	                                li+='<div class="custom-head">'
	                                    +'<div class="vip">'
	                                    +    '<div class="custom-head-img">'
	                                    +        '<img src="/assets/avatar.png"/>'
	                                    +   '</div>'
	                                    +   '<div class="custom-head-con">'
	                                    +       '<div class="customer">'+user_name+'</div>'
	                                    +       '<div class="custom-head-card">'
	                                    +            '<span>'+lang('ORDER_YUE')+'：<span class="balance">'+item.user.balance+'</span></span><span class="custom-head-discount">'+lang('ORDER_ZHEKOU')+'：<span class="discount">'+item.user.level.discount+'</span></span>'
	                                    +      '</div>'
	                                    +   '</div>'
	                                    +'</div>'
	                                    +'</div>'
	
	                            }
	                            li+='<div class="custom-body">';
	                            li+='<div class="custom-menu" style="height: 240px">';
	                            $.each(item.items,function (i,list) {
	                            	
	                                var unit='';
	                                for(var i in units){
	                                    if(list.unit == units[i].id){
	                                       if(SITE_LANG=='chinese'){
	                                		 unit='/'+units[i].title;   
	                                	}else{
	                                		 unit='/'+units[i].en_title;   
	                                	}
	                                    }
	                                }
	                                li+= '<div class="custom-menu-list">'
	                                    +     '<div class="custom-menu-list-name">'+(SITE_LANG=='chinese'?list.p_title:list.p_en_title)+'('+(SITE_LANG=='chinese'?list.title:list.en_title)+')'+'</div>'
	                                    +      '<span class="money">￡<span class="custom-menu-list-price">'+list.price+unit+'</span></span>'
	                                    +      '<div class="pull-right">'
	                                    +         '<span class="menu-list-num">x'+list.qty+'</span>'
	                                    +       '</div>'
	                                    + '</div>'
	                            });
	
	                            li+='</div>';
	                            li+= '<div class="custom-total">'
	                                +      '<div class="custom-total-num">'
	                                +         '<span>'+lang('ORDER_NUM')+'：<span class="totalNum">'+item.total_number+'</span></span>'
	                                +         '<span>'+lang('ORDER_TOTAL')+'：￡<span class="totalPrice">'+item.total_fee+'</span></span>'
	                                +         '<span>'+lang('ORDER_YOUHUI')+'：￡<span class="discountPrice">'+item.privilege+'</span></span>'
	                                +      '</div>'
	                                +      '<div class="custom-total-price">'
	                                +         '<span class="pull-right">'+lang('ORDER_YINGFU')+'：￡<span class="deal">'+(item.total_fee-item.privilege).toFixed(2)+'</span></span>'
	                                +      '</div>'
	                                +'</div>'
	                                + '<div class="custom-operate">'
	                                +       '<div class="btn-left" style="margin-right: 10px">'+lang('ORDER_DELETE')+'</div>'
	                                +       '<a href="/cashier/index/index/index?id='+item.id+'"><div class="btn-right">'+lang('ORDER_QUDAN')+'</div></a>'
	                                + '</div>'
	                                + '</div>'
	                                +'</li>';
	                        });
	                        $('.custom-con ul').html(li);
	                        if(parseInt(total)>1){
	                            var pageHtml=paginate(total,page);
	                            $('.shop-pages').html(pageHtml);
	                        }
	                    }else{
	                    	
	                    	 $('.custom-con ul').html('<div style="text-align: center;"><img style="margin:20px auto;width:100px;height:90px" src="../../../assets/cashier/img/empty-list.png"/><p style="margin-top:10px;color: #666666;">暂无挂单，请查看其它信息</p></div>');
	                    	
	                    }
                    }
                })
            }
            
        })
    </script>
</body>
</html>